import React, { useState, useEffect } from 'react'
import { View, Image,Text } from '@tarojs/components'
import { AtList, AtListItem , AtButton,AtTextarea } from "taro-ui"
import Taro from '@tarojs/taro'
import ToLogin from '../../compontents/toLogin'


import './index.less'
import "taro-ui/dist/style/components/list.scss";
import "taro-ui/dist/style/components/icon.scss";
import "taro-ui/dist/style/components/modal.scss";
import "taro-ui/dist/style/components/button.scss";
import "taro-ui/dist/style/components/toast.scss";


export default (props: any) => {
  const wxinfo:any = Taro.getStorageSync('wxinfo')
  const {openid} = JSON.parse(wxinfo)
  const list = [
    // {
    //   title: '个人信息',
    // },
    {
      title: '清理缓存',
    },
  ]
  const navClick=(item:any)=>{
    if(item.title==='个人信息'){
      Taro.showToast({
        title:'昵称：111',
        icon:'none'
      })
    }else if(item.title==='清理缓存'){
      Taro.showToast({
        title:'清除成功'
      })
      // Taro.removeStorage({
      //   key: 'key',
      //   success: function (res) {
      //     console.log(res)
      //   }
      // })
    }
  }
  const [isOpened,setIsOpened]=useState(false)
  const onClose=()=>{
    setIsOpened(false)
  }
  const loginout=()=>{
    Taro.removeStorageSync('info')
    Taro.navigateBack({
      delta: 1
    })
  }
  return (
    <View className='listNav'>
      <ToLogin url='/pages/set/index'></ToLogin>
      <AtList>
        {
          list.map((item, i) => (
            <AtListItem
              className='navLi'
              onClick={()=>{navClick(item)}}
              key={i}
              title={item.title}
              arrow='right'
            />
          ))
        }
      </AtList>
      <AtTextarea value={openid} onChange={()=>{}}  count={false}/>
      <AtButton onClick={loginout} className='loginout' type='primary' size='normal'>退出登录</AtButton>
    </View>
  )
}
